import { appStore } from '@renderer/store/modules/app'

export const useGridShow = () => {
  // 初始化标签
  const DEFAULT_LABELS = []
  const initLabels = () => {
    const { gridSize } = appStore
    for (let i = 1; i <= gridSize * gridSize + 1; i++) {
      DEFAULT_LABELS.push(Math.pow(2, i).toString())
    }
  }
  initLabels()
  // 根据值显示标签
  const showLabel = (value: number) => {
    return value ? DEFAULT_LABELS[value - 1] : ''
  }
  // 标签字号大小
  const labelFont = (value: number) => {
    let result
    if (value < 10) {
      result = ''
    } else if (value < 20) {
      result = 'grid-item--sm'
    } else {
      result = 'grid-item--xs'
    }
    return result
  }
  return {
    showLabel,
    labelFont
  }
}
